home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #3 / amigamamagazinepolishissue1998.iso / maksiu / lists / amoslist-1295.lzh / AMOSLIST / 000082_amos-request@svcs1.digex.net_Fri Dec 15 10:41:25 1995.msg < prev    next >
Internet Message Format  |  1995-12-31  |  4KB

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224]) by mail1.access.digex.net (8.6.12/8.6.12) with ESMTP id KAA13480;  for <mcox@access.digex.net> ; Fri, 15 Dec 1995 10:41:23 -0500
  2. Received: (from daemon@localhost) by svcs1.digex.net (8.6.12/8.6.12) id GAA07155 for amos-out; Fri, 15 Dec 1995 06:42:47 -0500
  3. Received: from mail1.access.digex.net (mail1.access.digex.net [205.197.247.2]) by svcs1.digex.net (8.6.12/8.6.12) with ESMTP id GAA07150 for <amos-list@svcs1.digex.net>; Fri, 15 Dec 1995 06:42:43 -0500
  4. Received: from paaltjens.si.hhs.nl (pp@paaltjens.si.hhs.nl [145.52.80.3]) by mail1.access.digex.net (8.6.12/8.6.12) with SMTP id GAA18914;  for <amos-list@access.digex.net> ; Fri, 15 Dec 1995 06:42:36 -0500
  5. From: v942360@si.hhs.nl
  6. Received: from si.hhs.nl by paaltjens.si.hhs.nl 
  7.           id <13859-0@paaltjens.si.hhs.nl>; Fri, 15 Dec 1995 12:41:25 +0100
  8. Received: by brulez.si.hhs.nl (5.0/SMI-SVR4) id AA07904;
  9.           Fri, 15 Dec 1995 12:39:49 --100
  10. Date: Fri, 15 Dec 1995 12:39:49 --100
  11. Message-Id: <9512151139.AA07904@brulez.si.hhs.nl>
  12. To: amos-list@access.digex.net
  13. Subject: Re: Help me a little. Please!
  14. X-Sun-Charset: US-ASCII
  15. content-length: 2647
  16. Status: RO
  17. X-Status: 
  18.  
  19. nygren@wineasy.se (Anders Nygren) wrote a plea FOR HELP ON 11.12.1995.
  20. He also got a reply from Chris hodges, however, I have something to add.
  21. First he asked some questions, after wich he asked the following one:
  22.  
  23. > AN> and is it possible
  24. > AN> to redimension a variable after I already have dimensioned it?
  25. > No. For your file requester thingy, I would use a bank for the directory
  26. > data or an array of fixed maximum size for the data.
  27.  
  28. Now, in a way Chris is correct, you cannot redimension an array after you have dimensioned it, but, look at this:
  29.  
  30. Rem Global or non global??
  31. Rem That's the question.
  32. Rem a simple example, by Jeroen Knoester (v942360@si.hhs.nl)
  33. '
  34. Rem Global vars:
  35. Dim array1(10,10)
  36. Global array1()
  37. Rem now this array can never be altered in size, but...
  38. '
  39. Procedure example
  40. Rem Create an array
  41. count=Rnd(100)
  42. Print count
  43. '
  44. Dim array2(count)
  45. Rem this array is now dimensioned, right..
  46. Rem So.. it cannot be altered in size, right..
  47. Rem Correct, BUT this is a LOCAL array.. If the procedure is exited
  48. Rem and then reentered later, the main program will have forgotten all
  49. Rem about the array, so.. It will locally redimension the array, with a
  50. Rem different size.
  51. '
  52. End Proc
  53. '
  54. Rem Main loop
  55. '
  56. While inkey$=""
  57.   example
  58. Wend
  59. End
  60.  
  61. This little program will show you the benefits of local vars over global ones.
  62. What happens is this:
  63. In the main program, the computer knows nothing about the array in the procedure
  64. example. While inside the procedure, the array is dimensioned, with a random
  65. size. When this procedure is exited, the computer will totally forget the
  66. array dimensioned INSIDE the procedure. When the program then calls the procedure again, the computer will redimension the array, simply because according to the computer, the array is not there.
  67.  
  68. This poses a single problem, how to get the information you need from this procedure to the outside world..
  69. Well, you use a single global var as help. What you do is this: 
  70.  
  71. You read the information you need from your file selector, wich is a single file. This information you stick into a global var from the main program BEFORE you
  72. exit the procedure. This way you can redimension your array, and still get the
  73. information you need from it.
  74.  
  75. If you need the array to be known among multiple procedures, you simply declare it as a Shared var in the other procedure to use the array, like this:
  76.  
  77. Procedure Needs_your_array
  78.    Shared array()
  79.    Rem code goes here..
  80. End Proc
  81.  
  82. I hope this helps... See you,
  83.  
  84. Jeroen Knoester, v942360@si.hhs.nl
  85. --Check out the Power Programs homepage at http://www.si.hhs.nl/~v942360/Amiga.html-- A500, 68000 7 Mhz!! Still running!!
  86.